﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Common;

namespace Library.Entity
{
    public class Member : IdCodeName
    {
        public int MemberTypeId = 0;
        public DateTime JoinDate = StaticValue.NullDate;
        public Gender Gender = Gender.Male;
        public string Address = "";
        public string Phone = "";
        public string IDCardNo = "";
        public IDCardType IDCardType = IDCardType.KTP;
        public int MaxBorrow = 0;
        public int MemberClassId = 0;
        
        public Member()
        {
            
        }
        public Member(DbDataReader dr)
        {
            Id = DataConversion.ConvertToInt32(dr, "Id");
            Code = DataConversion.ConvertToString(dr, "Code");
            Name = DataConversion.ConvertToString(dr, "Name");
            Remark = DataConversion.ConvertToString(dr, "Remark");
            CreatedDate = DataConversion.ConvertToDateTime(dr, "CreatedDate");
            ModifiedDate = DataConversion.ConvertToDateTime(dr, "ModifiedDate");
            CreatedUserId = DataConversion.ConvertToInt32(dr, "CreatedUserId");
            ModifiedUserId = DataConversion.ConvertToInt32(dr, "ModifiedUserId");

            MemberTypeId = DataConversion.ConvertToInt32(dr, "MemberTypeId");
            JoinDate = DataConversion.ConvertToDateTime(dr, "JoinDate");
            Gender = (Gender)DataConversion.ConvertToEnum(dr, "Gender", typeof(Gender));
            Address = DataConversion.ConvertToString(dr, "Address");
            Phone = DataConversion.ConvertToString(dr, "Phone");
            IDCardNo = DataConversion.ConvertToString(dr, "IDCardNo");
            IDCardType = (IDCardType)DataConversion.ConvertToEnum(dr, "IDCardType", typeof(IDCardType));
            MaxBorrow = DataConversion.ConvertToInt32(dr, "MaxBorrow");
            MemberClassId = DataConversion.ConvertToInt32(dr, "MemberClassId");
        }
    }
}